home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / Moderate.php < prev    next >
Encoding:
PHP Script  |  2002-06-12  |  38.5 KB  |  1,333 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Moderation core module
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 19th February 2002
  19. |
  20. |   > Module Version 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25. $idx = new Moderate;
  26.  
  27. class Moderate {
  28.  
  29.     var $output    = "";
  30.     var $base_url  = "";
  31.     var $html      = "";
  32.  
  33.     var $moderator = "";
  34.     var $forum     = array();
  35.     var $topic     = array();
  36.     
  37.     var $upload_dir = "";
  38.  
  39.     
  40.     /***********************************************************************************/
  41.     //
  42.     // Our constructor, load words, load skin, print the topic listing
  43.     //
  44.     /***********************************************************************************/
  45.     
  46.     function Moderate() {
  47.     
  48.         global $ibforums, $DB, $std, $print, $skin_universal, $HTTP_POST_VARS;
  49.         
  50.         // Make sure this is a POST request, not a naughty IMG redirect
  51.         
  52.         if ($ibforums->input['CODE'] != '04' && $ibforums->input['CODE'] != '20' && $ibforums->input['CODE'] != '22')
  53.         {
  54.         
  55.             if ($HTTP_POST_VARS['act'] == '')
  56.             {
  57.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'incorrect_use') );
  58.             }
  59.             
  60.         }
  61.         
  62.         require "./Skin/".$ibforums->skin_id."/skin_mod.php";
  63.         
  64.         //-------------------------------------
  65.         // Compile the language file
  66.         //-------------------------------------
  67.         
  68.         $ibforums->lang  = $std->load_words($ibforums->lang, 'lang_mod', $ibforums->lang_id);
  69.  
  70.         $this->html      = new skin_mod();
  71.         
  72.         //-------------------------------------
  73.         // Check the input
  74.         //-------------------------------------
  75.         
  76.         if ($ibforums->input['t'])
  77.         {
  78.             $ibforums->input['t'] = $std->is_number($ibforums->input['t']);
  79.             if (! $ibforums->input['t'] )
  80.             {
  81.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files') );
  82.             }
  83.             else
  84.             {
  85.                 $DB->query("SELECT tid, title, description, posts, state, starter_id, pinned, forum_id from ibf_topics WHERE tid='".$ibforums->input['t']."'");
  86.                 $this->topic = $DB->fetch_row();
  87.                 
  88.                 if (empty($this->topic['tid']))
  89.                 {
  90.                     $std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files') );
  91.                 }
  92.             }
  93.         }
  94.         
  95.         if ($ibforums->input['p'])
  96.         {
  97.             $ibforums->input['p'] = $std->is_number($ibforums->input['p']);
  98.             if (! $ibforums->input['p'] )
  99.             {
  100.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files') );
  101.             }
  102.         }
  103.         
  104.         $ibforums->input['f'] = $std->is_number($ibforums->input['f']);
  105.         if (! $ibforums->input['f'] )
  106.         {
  107.             $std->Error( array( 'LEVEL' => 1,'MSG' => 'missing_files') );
  108.         }
  109.         
  110.         $ibforums->input['st'] = $ibforums->input['st'] ? $std->is_number($ibforums->input['st']) : 0;
  111.         
  112.         
  113.         //-------------------------------------
  114.         // Get the forum info based on the forum ID, get the category name, ID, and get the topic details
  115.         //-------------------------------------
  116.         
  117.         $DB->query("SELECT f.*, c.name as cat_name, c.id as cat_id from ibf_forums f, ibf_categories c WHERE f.id=".$ibforums->input['f']." and c.id=f.category");
  118.         
  119.         $this->forum = $DB->fetch_row();
  120.         
  121.         
  122.         //-------------------------------------
  123.         // Error out if we can not find the forum
  124.         //-------------------------------------
  125.         
  126.         if (!$this->forum['id'])
  127.         {
  128.             $std->Error( array( LEVEL => 1, MSG => 'missing_files') );
  129.         }
  130.         
  131.         $this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
  132.         
  133.         if ($ibforums->member['id'])
  134.         {
  135.             if ($ibforums->member['g_is_supmod'] != 1)
  136.             {
  137.                 $DB->query("SELECT * FROM ibf_moderators WHERE forum_id='".$this->forum['id']."' AND member_id='".$ibforums->member['id']."'");
  138.                 $this->moderator = $DB->fetch_row();
  139.             }
  140.         }
  141.         
  142.         $this->upload_dir = $ibforums->vars['upload_dir'];
  143.         
  144.         //-------------------------------------
  145.         // Convert the code ID's into something
  146.         // use mere mortals can understand....
  147.         //-------------------------------------
  148.         
  149.         switch ($ibforums->input['CODE']) {
  150.             case '02':
  151.                 $this->move_form();
  152.                 break;
  153.             case '03':
  154.                 $this->delete_form();
  155.                 break;
  156.             case '04':
  157.                 $this->delete_post();
  158.                 break;
  159.             case '05':
  160.                 $this->edit_form();
  161.                 break;
  162.             case '00':
  163.                 $this->close_topic();
  164.                 break;
  165.             case '01':
  166.                 $this->open_topic();
  167.                 break;
  168.             case '08':
  169.                 $this->delete_topic();
  170.                 break;
  171.             case '12':
  172.                 $this->do_edit();
  173.                 break;
  174.             case '14':
  175.                 $this->do_move();
  176.                 break;
  177.             case '15':
  178.                 $this->pin_topic();
  179.                 break;
  180.             case '16':
  181.                 $this->unpin_topic();
  182.                 break;
  183.             case '17':
  184.                 $this->rebuild_topic();
  185.                 break;
  186.             //-------------------------
  187.             case '20':
  188.                 $this->poll_edit_form();
  189.                 break;
  190.             case '21':
  191.                 $this->poll_edit_do();
  192.                 break;
  193.             //-------------------------
  194.             case '22':
  195.                 $this->poll_delete_form();
  196.                 break;
  197.             case '23':
  198.                 $this->poll_delete_do();
  199.                 break;
  200.             //-------------------------
  201.             default:
  202.                 $this->moderate_error();
  203.                 break;
  204.         }
  205.         
  206.         // If we have any HTML to print, do so...
  207.         
  208.         $print->add_output("$this->output");
  209.         $print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
  210.       
  211.     }
  212.     
  213.     
  214.     /*************************************************/
  215.     // EDIT POLL FORM:
  216.     // ---------------
  217.     //
  218.     /*************************************************/
  219.     
  220.     
  221.     function poll_delete_form() {
  222.         global $std, $ibforums, $DB, $print;
  223.         
  224.         $passed = 0;
  225.         
  226.         if ($ibforums->member['g_is_supmod'] == 1) {
  227.             $passed = 1;
  228.         }
  229.         
  230.         else if ($this->moderator['delete_topic'] == 1) {
  231.             $passed = 1;
  232.         }
  233.         else {
  234.             $passed = 0;
  235.         }
  236.         
  237.         if ($passed != 1) $this->moderate_error();
  238.         
  239.         if (empty($this->topic['tid']))
  240.         {
  241.             $this->moderate_error();
  242.         }
  243.         
  244.         $DB->query("SELECT * FROM ibf_polls WHERE tid='".$this->topic['tid']."'");
  245.         $poll_data = $DB->fetch_row();
  246.         
  247.         if (! $poll_data['pid'])
  248.         {
  249.             $this->moderate_error();
  250.         }
  251.         
  252.         $this->output = $this->html_start_form( array( 1 => array( 'CODE', '23' ),
  253.                                                        2 => array( 't' , $this->topic['tid'] ),
  254.                                                        3 => array( 'f' , $this->forum['id']  ),
  255.                                                )      );
  256.                                                
  257.         $this->output .= $this->html->table_top( $ibforums->lang['pd_top']." ".$this->forum['name']." > ".$this->topic['title'] );
  258.         
  259.         $this->output .= $this->html->mod_exp( $ibforums->lang['pd_text'] );        
  260.                 
  261.         $this->output .= $this->html->end_form( $ibforums->lang['pd_submit'] );
  262.         
  263.         $this->page_title = $ibforums->lang['pd_top'].$this->topic['title'];
  264.         
  265.         $this->nav = array ( "<a href='{$this->base_url}&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",
  266.                              "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>"
  267.                            );
  268.     }
  269.     
  270.     function poll_delete_do() {
  271.         global $std, $ibforums, $DB, $print;
  272.         
  273.         $passed = 0;
  274.         
  275.         if ($ibforums->member['g_is_supmod'] == 1) {
  276.             $passed = 1;
  277.         }
  278.         
  279.         else if ($this->moderator['delete_topic'] == 1) {
  280.             $passed = 1;
  281.         }
  282.         else {
  283.             $passed = 0;
  284.         }
  285.         
  286.         if ($passed != 1) $this->moderate_error();
  287.         
  288.         if (empty($this->topic['tid']))
  289.         {
  290.             $this->moderate_error();
  291.         }
  292.         
  293.         // Remove the poll
  294.         
  295.         $DB->query("DELETE FROM ibf_polls WHERE tid='".$this->topic['tid']."'");
  296.         
  297.         // Remove from poll votes
  298.         
  299.         $DB->query("DELETE FROM ibf_voters WHERE tid='".$this->topic['tid']."'");
  300.         
  301.         // Update topic
  302.         
  303.         $DB->query("UPDATE ibf_topics SET poll_state='', last_vote='', total_votes='' WHERE tid='".$this->topic['tid']."'");
  304.         
  305.         // Boing!
  306.         
  307.         $print->redirect_screen( $ibforums->lang['pd_redirect'], "act=ST&f=".$this->forum['id']."&t=".$this->topic['tid']."&st=".$ibforums->input['st'] );
  308.         
  309.     }
  310.     
  311.     
  312.     function poll_edit_do() {
  313.         global $std, $ibforums, $DB, $print;
  314.         
  315.         $passed = 0;
  316.         
  317.         if ($ibforums->member['g_is_supmod'] == 1)
  318.         {
  319.             $passed = 1;
  320.         }
  321.         
  322.         else if ($this->moderator['edit_post'] == 1)
  323.         {
  324.             $passed = 1;
  325.         }
  326.         else
  327.         {
  328.             $passed = 0;
  329.         }
  330.         
  331.         if ($passed != 1) $this->moderate_error();
  332.         
  333.         if (empty($this->topic['tid']))
  334.         {
  335.             $this->moderate_error();
  336.         }
  337.         
  338.         $DB->query("SELECT * FROM ibf_polls WHERE tid='".$this->topic['tid']."'");
  339.         $poll_data = $DB->fetch_row();
  340.         
  341.         if (! $poll_data['pid'])
  342.         {
  343.             $this->moderate_error();
  344.         }
  345.         
  346.         $poll_answers = unserialize(stripslashes($poll_data['choices']));
  347.         
  348.         reset($poll_answers);
  349.         $new_poll_array = array();
  350.         
  351.         foreach ($poll_answers as $entry)
  352.         {
  353.             $id     = $entry[0];
  354.             $choice = $ibforums->input['POLL_'.$id];
  355.             $votes  = $entry[2];
  356.             
  357.             $new_poll_array[] = array( $id, $choice, $votes);
  358.         }
  359.         
  360.         $poll_data['choices'] = addslashes(serialize($new_poll_array));
  361.         
  362.         $DB->query("UPDATE ibf_polls SET ".
  363.                      "choices='"  . $poll_data['choices'] . "' ".
  364.                      "WHERE tid='" . $this->topic['tid']    . "'");
  365.                      
  366.         //------------------------
  367.         
  368.         // Update the topic table to change the poll_only value.
  369.         
  370.         $poll_state = $ibforums->input['pollonly'] == 1 ? 'closed' : 'open';
  371.         
  372.         $DB->query("UPDATE ibf_topics SET poll_state='$poll_state' WHERE tid='".$this->topic['tid']."'");
  373.         
  374.         $this->moderate_log("Edited a Poll");
  375.     
  376.         $print->redirect_screen( $ibforums->lang['pe_done'], "act=ST&f=".$this->forum['id']."&t=".$this->topic['tid']."&st=".$ibforums->input['st'] );
  377.  
  378.     }
  379.     
  380.     
  381.     //--------------------------------------
  382.     
  383.     
  384.     function poll_edit_form() {
  385.         global $std, $ibforums, $DB, $print;
  386.         
  387.         $passed = 0;
  388.         
  389.         if ($ibforums->member['g_is_supmod'] == 1) {
  390.             $passed = 1;
  391.         }
  392.         
  393.         else if ($this->moderator['edit_post'] == 1) {
  394.             $passed = 1;
  395.         }
  396.         else {
  397.             $passed = 0;
  398.         }
  399.         
  400.         if ($passed != 1) $this->moderate_error();
  401.         
  402.         if (empty($this->topic['tid']))
  403.         {
  404.             $this->moderate_error();
  405.         }
  406.         
  407.         $DB->query("SELECT * FROM ibf_polls WHERE tid='".$this->topic['tid']."'");
  408.         $poll_data = $DB->fetch_row();
  409.         
  410.         if (! $poll_data['pid'])
  411.         {
  412.             $this->moderate_error();
  413.         }
  414.         
  415.         $this->output = $this->html_start_form( array( 1 => array( 'CODE', '21' ),
  416.                                                        2 => array( 't' , $this->topic['tid'] ),
  417.                                                        3 => array( 'f' , $this->forum['id']  ),
  418.                                                )      );
  419.                                                
  420.         $this->output .= $this->html->table_top( $ibforums->lang['pe_top']." ".$this->forum['name']." > ".$this->topic['title'] );
  421.         
  422.         $poll_answers = unserialize(stripslashes($poll_data['choices']));
  423.         
  424.         reset($poll_answers);
  425.         
  426.         foreach ($poll_answers as $entry)
  427.         {
  428.             $id     = $entry[0];
  429.             $choice = $entry[1];
  430.             $votes  = $entry[2];
  431.             
  432.             $this->output .= $this->html->poll_entry($id, $choice);
  433.             
  434.         }
  435.                 
  436.         $this->output .= $this->html->poll_select_form();        
  437.                 
  438.         $this->output .= $this->html->end_form( $ibforums->lang['pe_submit'] );
  439.         
  440.         $this->page_title = $ibforums->lang['pe_top'].$this->topic['title'];
  441.         
  442.         $this->nav = array ( "<a href='{$this->base_url}&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",
  443.                              "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>"
  444.                            );
  445.     }
  446.     
  447.     /*************************************************/
  448.     // MOVE FORM:
  449.     // ---------------
  450.     //
  451.     /*************************************************/
  452.     
  453.     function move_form() {
  454.         global $std, $ibforums, $DB, $print;
  455.         
  456.         $passed = 0;
  457.         
  458.         if ($ibforums->member['g_is_supmod'] == 1) {
  459.             $passed = 1;
  460.         }
  461.         
  462.         else if ($this->moderator['move_topic'] == 1) {
  463.             $passed = 1;
  464.         }
  465.         else {
  466.             $passed = 0;
  467.         }
  468.         
  469.         if ($passed != 1) $this->moderate_error();
  470.         
  471.         if (empty($this->topic['tid']))
  472.         {
  473.             $this->moderate_error();
  474.         }
  475.         
  476.         $this->output = $this->html_start_form( array( 1 => array( 'CODE', '14' ),
  477.                                                        2 => array( 'tid' , $this->topic['tid'] ),
  478.                                                        3 => array( 'sf'  , $this->forum['id']  ),
  479.                                                )      );
  480.                                                
  481.         $jump_html = $std->build_forum_jump('no_html');
  482.                                          
  483.         $this->output .= $this->html->table_top( $ibforums->lang['top_move']." ".$this->forum['name']." > ".$this->topic['title'] );
  484.         $this->output .= $this->html->mod_exp( $ibforums->lang['move_exp'] );
  485.         $this->output .= $this->html->move_form( $jump_html , $this->forum['name']);
  486.         $this->output .= $this->html->end_form( $ibforums->lang['submit_move'] );
  487.         
  488.         $this->page_title = $ibforums->lang['t_move'].": ".$this->topic['title'];
  489.         
  490.         $this->nav = array ( "<a href='{$this->base_url}&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",
  491.                              "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>"
  492.                            );
  493.     }
  494.     
  495.     /*************************************************/
  496.     
  497.     function do_move() {
  498.         global $std, $ibforums, $DB, $print;
  499.         
  500.         $passed = 0;
  501.         
  502.         if ($ibforums->member['g_is_supmod'] == 1) {
  503.             $passed = 1;
  504.         }
  505.         
  506.         else if ($this->moderator['move_topic'] == 1) {
  507.             $passed = 1;
  508.         }
  509.         else {
  510.             $passed = 0;
  511.         }
  512.         
  513.         if ($passed != 1) $this->moderate_error();
  514.         
  515.         //----------------------------------
  516.         // Check for input..
  517.         //----------------------------------
  518.         
  519.         if ($ibforums->input['sf'] == "")
  520.         {
  521.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'move_no_source' ) );
  522.         }
  523.         
  524.         //----------------------------------
  525.         
  526.         if ($ibforums->input['move_id'] == "" or $ibforums->input['move_id'] == -1)
  527.         {
  528.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'move_no_forum' ) );
  529.         }
  530.         
  531.         //----------------------------------
  532.         
  533.         if ($ibforums->input['move_id'] == $ibforums->input['sf'])
  534.         {
  535.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'move_same_forum' ) );
  536.         }
  537.         
  538.         //----------------------------------
  539.         
  540.         $DB->query("SELECT id, subwrap FROM ibf_forums WHERE id IN(".$ibforums->input['sf'].",".$ibforums->input['move_id'].")");
  541.         
  542.         if ($DB->get_num_rows() != 2)
  543.         {
  544.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'move_no_forum' ) );
  545.         }
  546.         
  547.         //-----------------------------------
  548.         // Check for an attempt to move into a subwrap forum
  549.         //-----------------------------------
  550.         
  551.         while ( $f = $DB->fetch_row() )
  552.         {
  553.             if ($f['subwrap'] == 1)
  554.             {
  555.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'move_no_forum' ) );
  556.             }
  557.         }
  558.         
  559.         
  560.         $DB->query("SELECT * FROM ibf_topics WHERE tid='".$ibforums->input['tid']."'");
  561.         
  562.         if ( ! $this->topic = $DB->fetch_row() )
  563.         {
  564.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'move_no_forum' ) );
  565.         }
  566.         
  567.         //----------------------------------
  568.         // We know that $this->topic is set..
  569.         //----------------------------------
  570.         
  571.         $source = $ibforums->input['sf'];
  572.         $moveto = $ibforums->input['move_id'];
  573.         $tid    = $ibforums->input['tid'];
  574.         
  575.         //----------------------------------
  576.         // Update the topic
  577.         //----------------------------------
  578.         
  579.         $DB->query("UPDATE ibf_topics SET forum_id='$moveto' WHERE forum_id='$source' AND tid='$tid'");
  580.         
  581.         //----------------------------------
  582.         // Update the posts
  583.         //----------------------------------
  584.         
  585.         $DB->query("UPDATE ibf_posts SET forum_id='$moveto' WHERE forum_id='$source' AND topic_id='$tid'");
  586.         
  587.         //----------------------------------
  588.         // Update the polls
  589.         //----------------------------------
  590.         
  591.         $DB->query("UPDATE ibf_polls SET forum_id='$moveto' WHERE forum_id='$source' AND tid='$tid'");
  592.         
  593.         //----------------------------------
  594.         // Are we leaving a link?
  595.         //----------------------------------
  596.         
  597.         if ($ibforums->input['leave'] == 'y')
  598.         {
  599.             //----------------------------------
  600.             // Insert a new "link" topic...
  601.             //----------------------------------
  602.             
  603.             $db_string = $DB->compile_db_insert_string( array (
  604.                                                                  'title'            => $this->topic['title'],
  605.                                                                  'description'      => $this->topic['description'],
  606.                                                                  'state'            => 'link',
  607.                                                                  'posts'            => 0,
  608.                                                                  'views'            => 0,
  609.                                                                  'starter_id'       => $this->topic['starter_id'],
  610.                                                                  'start_date'       => $this->topic['start_date'],
  611.                                                                  'starter_name'     => $this->topic['starter_name'],
  612.                                                                  'last_post'        => $this->topic['last_post'],
  613.                                                                  'forum_id'         => $source,
  614.                                                                  'approved'         => 1,
  615.                                                                  'pinned'           => 0,
  616.                                                                  'moved_to'         => $this->topic['tid'].'&'.$moveto,
  617.                                                                  'last_poster_id'   => $this->topic['last_poster_id'],
  618.                                                                  'last_poster_name' => $this->topic['last_poster_name']
  619.                                                      )        );
  620.                                                      
  621.             $DB->query("INSERT INTO ibf_topics (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
  622.             
  623.         }
  624.         
  625.         $this->moderate_log("Moved a topic");
  626.         
  627.         // Resync the forums..
  628.         
  629.         $this->recount($source);
  630.         
  631.         $this->recount($moveto);
  632.     
  633.         $print->redirect_screen( $ibforums->lang['p_moved'], "act=SF&f=".$this->forum['id']."&st=".$ibforums->input['st'] );
  634.         
  635.     }
  636.     
  637.     
  638.     /*************************************************/
  639.     
  640.     function delete_post() {
  641.         global $std, $ibforums, $DB, $print;
  642.         
  643.         $passed = 0;
  644.         
  645.         if ($ibforums->member['g_is_supmod'] == 1)
  646.         {
  647.             $passed = 1;
  648.         }
  649.         else if ($ibforums->member['g_delete_own_posts'] == 1)
  650.         {
  651.             $passed = 1;
  652.         }
  653.         else if ($this->moderator['delete_post'] == 1)
  654.         {
  655.             $passed = 1;
  656.         }
  657.         else 
  658.         {
  659.             $passed = 0;
  660.         }
  661.         
  662.         if ($passed != 1) $this->moderate_error();
  663.         
  664.         
  665.         // Get this post id.
  666.         
  667.         $DB->query("SELECT pid,attach_file, attach_id, post_date, new_topic from ibf_posts WHERE forum_id='".$this->forum['id']."' AND topic_id='".$this->topic['tid']."' and pid='".$ibforums->input['p']."'");
  668.         if ( ! $post = $DB->fetch_row() )
  669.         {
  670.             $this->moderate_error();
  671.         }
  672.         
  673.         // Check to make sure that this isn't the first post in the topic..
  674.         
  675.         if ($post['new_topic'] == 1)
  676.         {
  677.             $this->moderate_error('no_delete_post');
  678.         }
  679.         
  680.         //---------------------------------------
  681.         // Is there an attachment to this post?
  682.         //---------------------------------------
  683.         
  684.         if ($post['attach_id'] != "")
  685.         {
  686.             if (is_file($this->upload_dir."/".$post['attach_id']))
  687.             {
  688.                 unlink ($this->upload_dir."/".$post['attach_id']);
  689.             }
  690.         }
  691.         
  692.         //---------------------------------------
  693.         // delete the post
  694.         //---------------------------------------
  695.         
  696.         $DB->query("DELETE from ibf_posts WHERE topic_id='".$this->topic['tid']."' and pid='".$post['pid']."'");
  697.         
  698.         //---------------------------------------
  699.         // Update the stats
  700.         //---------------------------------------
  701.         
  702.         $DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES-1");
  703.         
  704.         //---------------------------------------
  705.         // Get the latest post details
  706.         //---------------------------------------
  707.         
  708.         $DB->query("SELECT post_date, author_id, author_name from ibf_posts WHERE topic_id='".$this->topic['tid']."' and queued <> 1 ORDER BY pid DESC");
  709.         $last_post = $DB->fetch_row();
  710.             
  711.         $DB->query("UPDATE ibf_topics SET last_post='"        .$last_post['post_date']   ."', ".
  712.                                          "last_poster_id='"   .$last_post['author_id']   ."', ".
  713.                                          "last_poster_name='" .$last_post['author_name'] ."', ".
  714.                                          "posts=posts-1 WHERE tid='".$this->topic['tid']."'");
  715.                                          
  716.         //---------------------------------------
  717.         // If we deleted the last post in a topic that was
  718.         // the last post in a forum, best update that :D
  719.         //---------------------------------------
  720.         
  721.         if ($this->forum['last_id'] == $this->topic['tid'])
  722.         {
  723.             $DB->query("SELECT title, tid, last_post, last_poster_id, last_poster_name "
  724.                       ."FROM ibf_topics WHERE forum_id='".$this->forum['id']."' AND approved=1 "
  725.                       ."ORDER BY last_post DESC LIMIT 0,1");
  726.                   
  727.             $tt = $DB->fetch_row();
  728.             
  729.             $db_string = $DB->compile_db_update_string( array(
  730.                                                                last_title       => $tt['title']            ? $tt['title']            : "",
  731.                                                                last_id          => $tt['tid']              ? $tt['tid']              : "",
  732.                                                                last_post        => $tt['last_post']        ? $tt['last_post']        : "",
  733.                                                                last_poster_name => $tt['last_poster_name'] ? $tt['last_poster_name'] : "",
  734.                                                                last_poster_id   => $tt['last_poster_id']   ? $tt['last_poster_id']   : "",
  735.                                                       )      );
  736.             
  737.             $DB->query("UPDATE ibf_forums SET ".$db_string.",posts=posts-1 WHERE id='".$this->forum['id']."'");
  738.         }
  739.         
  740.         $this->moderate_log("Deleted a post");
  741.     
  742.         $print->redirect_screen( $ibforums->lang['post_deleted'], "act=ST&f=".$this->forum['id']."&t=".$this->topic['tid']."&st=".$ibforums->input['st'] );
  743.  
  744.     
  745.     }
  746.  
  747.     function rebuild_topic() {}
  748.     
  749.     /*************************************************/
  750.     // DELETE TOPIC:
  751.     // ---------------
  752.     //
  753.     /*************************************************/
  754.     
  755.     function delete_form() {
  756.         global $std, $ibforums, $DB, $print;
  757.         
  758.         $passed = 0;
  759.         
  760.         if ($ibforums->member['g_is_supmod'] == 1) {
  761.             $passed = 1;
  762.         }
  763.         
  764.         else if ($this->topic['starter_id'] == $ibforums->member['id'])
  765.         {
  766.             if ($ibforums->member['g_delete_own_topics'] == 1)
  767.             {
  768.                 $passed = 1;
  769.             }
  770.         }
  771.         
  772.         else if ($this->moderator['delete_topic'] == 1) {
  773.             $passed = 1;
  774.         }
  775.         else {
  776.             $passed = 0;
  777.         }
  778.         
  779.         if ($passed != 1) $this->moderate_error();
  780.         
  781.         if (empty($this->topic['tid'])) {
  782.             $this->moderate_error();
  783.         }
  784.         
  785.         $this->output = $this->html->delete_js();
  786.         
  787.         $this->output .= $this->html_start_form( array( 1 => array( 'CODE', '08' ),
  788.                                                         2 => array( 't', $this->topic['tid'] )
  789.                                                 )      );
  790.                                          
  791.         $this->output .= $this->html->table_top( $ibforums->lang['top_delete']." ".$this->forum['name']." > ".$this->topic['title'] );
  792.         $this->output .= $this->html->mod_exp( $ibforums->lang['delete_topic'] );
  793.         $this->output .= $this->html->end_form( $ibforums->lang['submit_delete'] );
  794.         
  795.         $this->page_title = $ibforums->lang['t_delete'].": ".$this->topic['title'];
  796.         
  797.         $this->nav = array ( "<a href='{$this->base_url}&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",
  798.                              "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>"
  799.                            );
  800.     }
  801.     
  802.     function delete_topic() {
  803.         global $std, $ibforums, $DB, $print;
  804.         
  805.         $passed = 0;
  806.         
  807.         if ($ibforums->member['g_is_supmod'] == 1) {
  808.             $passed = 1;
  809.         }
  810.         
  811.         else if ($this->topic['starter_id'] == $ibforums->member['id'])
  812.         {
  813.             if ($ibforums->member['g_delete_own_topics'] == 1)
  814.             {
  815.                 $passed = 1;
  816.             }
  817.         }
  818.         
  819.         else if ($this->moderator['delete_topic'] == 1) {
  820.             $passed = 1;
  821.         }
  822.         else {
  823.             $passed = 0;
  824.         }
  825.         
  826.         if ($passed != 1) $this->moderate_error();
  827.         
  828.         if (empty($this->topic['tid'])) {
  829.             $this->moderate_error();
  830.         }
  831.         
  832.         // Do we have a linked topic to remove?
  833.         
  834.         $DB->query("SELECT tid FROM ibf_topics WHERE state='link' AND moved_to='".$this->topic['tid'].'&'.$this->forum['id']."'");
  835.         
  836.         if ( $linked_topic = $DB->fetch_row() )
  837.         {
  838.             $DB->query("DELETE FROM ibf_topics WHERE tid='".$linked_topic['tid']."'");
  839.         }
  840.         
  841.         
  842.         // Remove polls assigned to this topic
  843.         
  844.         $DB->query("DELETE FROM ibf_polls WHERE tid='".$this->topic['tid']."'");
  845.         
  846.         // Remove poll voters
  847.         
  848.         $DB->query("DELETE FROM ibf_voters WHERE tid='".$this->topic['tid']."'");
  849.         
  850.         // Remove the topic itself
  851.         
  852.         $DB->query("DELETE FROM ibf_topics WHERE tid='".$this->topic['tid']."'");
  853.         
  854.         // Get the attach ID's and filenames
  855.         
  856.         $DB->query("SELECT attach_id, attach_hits, attach_file FROM ibf_posts WHERE attach_id <> '' AND topic_id='".$this->topic['tid']."'");
  857.         
  858.         // Remove the attachments
  859.         
  860.         if ( $DB->get_num_rows() )
  861.         {
  862.             while ( $r = $DB->fetch_row() )
  863.             {
  864.                 if (is_file($this->upload_dir."/".$r['attach_id']))
  865.                 {
  866.                     @unlink ($this->upload_dir."/".$r['attach_id']);
  867.                 }
  868.             }
  869.         }
  870.         
  871.         // Remove the posts
  872.         
  873.         $DB->query("DELETE FROM ibf_posts WHERE topic_id='".$this->topic['tid']."'");
  874.         
  875.         //------------------------------------------------
  876.         // Update the forum topic/post and stat counters.
  877.         //
  878.         // We also need to make sure the last forum id and
  879.         // title is correct.
  880.         //------------------------------------------------
  881.         
  882.         $DB->query("SELECT COUNT(tid) as tcount from ibf_topics WHERE approved=1");
  883.         $topics = $DB->fetch_row();
  884.         
  885.         $DB->query("SELECT COUNT(pid) as pcount from ibf_posts WHERE queued <> 1");
  886.         $posts  = $DB->fetch_row();
  887.         
  888.         $DB->query("SELECT COUNT(tid) as tcount from ibf_topics WHERE approved=1 and forum_id='".$this->forum['id']."'");
  889.         $f_topics = $DB->fetch_row();
  890.         
  891.         $DB->query("SELECT COUNT(pid) as pcount from ibf_posts WHERE queued <> 1 and forum_id='".$this->forum['id']."'");
  892.         $f_posts  = $DB->fetch_row();
  893.         
  894.         $this->forum['topics'] = $f_topics['tcount'];
  895.         $this->forum['posts']  = $f_posts['pcount'] - $f_topics['tcount'];
  896.         
  897.         $DB->query("SELECT title, tid, last_post, last_poster_id, last_poster_name "
  898.                   ."FROM ibf_topics WHERE forum_id='".$this->forum['id']."' AND approved=1 "
  899.                   ."ORDER BY last_post DESC LIMIT 0,1");
  900.                   
  901.         $tt = $DB->fetch_row();
  902.         
  903.         $db_string = $DB->compile_db_update_string( array(
  904.                                                            last_title       => $tt['title']            ? $tt['title']            : "",
  905.                                                            last_id          => $tt['tid']              ? $tt['tid']              : "",
  906.                                                            last_post        => $tt['last_post']        ? $tt['last_post']        : "",
  907.                                                            last_poster_name => $tt['last_poster_name'] ? $tt['last_poster_name'] : "",
  908.                                                            last_poster_id   => $tt['last_poster_id']   ? $tt['last_poster_id']   : "",
  909.                                                            topics           => $this->forum['topics'],
  910.                                                            posts            => $this->forum['posts']
  911.                                                   )      );
  912.         
  913.         $DB->query("UPDATE ibf_forums SET $db_string WHERE id='".$this->forum['id']."'");
  914.         
  915.         // Update the main board stats.
  916.         
  917.         $posts = $posts['pcount'] - $topics['tcount'];
  918.         
  919.         $DB->query("UPDATE ibf_stats SET TOTAL_TOPICS='".$topics['tcount']."', TOTAL_REPLIES='".$posts."'");
  920.         
  921.         $this->moderate_log("Deleted a topic");
  922.     
  923.         $print->redirect_screen( $ibforums->lang['p_deleted'], "act=SF&f=".$this->forum['id'] );
  924.     
  925.     }
  926.     
  927.     
  928.     /*************************************************/
  929.     // EDIT TOPIC:
  930.     // ---------------
  931.     //
  932.     /*************************************************/
  933.     
  934.     function edit_form() {
  935.         global $std, $ibforums, $DB, $print;
  936.         
  937.         $passed = 0;
  938.         
  939.         if ($ibforums->member['g_is_supmod'] == 1) {
  940.             $passed = 1;
  941.         }
  942.         
  943.         else if ($this->moderator['edit_topic'] == 1) {
  944.             $passed = 1;
  945.         }
  946.         else {
  947.             $passed = 0;
  948.         }
  949.         
  950.         if ($passed != 1) $this->moderate_error();
  951.         
  952.         if (empty($this->topic['tid']))
  953.         {
  954.             $this->moderate_error();
  955.         }
  956.         
  957.         $this->output = $this->html_start_form( array( 1 => array( 'CODE', '12' ),
  958.                                                        2 => array( 't', $this->topic['tid'] )
  959.                                                )      );
  960.                                          
  961.         $this->output .= $this->html->table_top( $ibforums->lang['top_edit']." ".$this->forum['name']." > ".$this->topic['title'] );
  962.         $this->output .= $this->html->mod_exp( $ibforums->lang['edit_topic'] );
  963.         $this->output .= $this->html->topictitle_fields( $this->topic['title'], $this->topic['description'] );
  964.         $this->output .= $this->html->end_form( $ibforums->lang['submit_edit'] );
  965.         
  966.         $this->page_title = $ibforums->lang['t_edit'].": ".$this->topic['title'];
  967.         
  968.         $this->nav = array ( "<a href='{$this->base_url}&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",
  969.                              "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>"
  970.                            );
  971.     }
  972.     
  973.     function do_edit() {
  974.         global $std, $ibforums, $DB, $print;
  975.         
  976.         $passed = 0;
  977.         
  978.         if ($ibforums->member['g_is_supmod'] == 1) {
  979.             $passed = 1;
  980.         }
  981.         
  982.         else if ($this->moderator['edit_topic'] == 1) {
  983.             $passed = 1;
  984.         }
  985.         else {
  986.             $passed = 0;
  987.         }
  988.         
  989.         if ($passed != 1) $this->moderate_error();
  990.         
  991.         if (empty($this->topic['tid'])) {
  992.             $this->moderate_error();
  993.         }
  994.         
  995.         if ($ibforums->input['TopicTitle'] == "") {
  996.             $std->Error( array( 'LEVEL' => 2, 'MSG' => 'no_topic_title' ) );
  997.         }
  998.         
  999.         $topic_title = preg_replace( "/'/", "/\\'/", $ibforums->input['TopicTitle'] );
  1000.         $topic_desc  = preg_replace( "/'/", "/\\'/", $ibforums->input['TopicDesc']  );
  1001.         
  1002.         $DB->query("UPDATE ibf_topics SET title='$topic_title', description='$topic_desc' WHERE tid='".$this->topic['tid']."'");
  1003.         
  1004.         if ($this->topic['tid'] == $this->forum['last_id'])
  1005.         {
  1006.             $DB->query("UPDATE ibf_forums SET last_title='$topic_title' WHERE id='".$this->forum['id']."'");
  1007.         }
  1008.         
  1009.         $this->moderate_log("Edited a topic title");
  1010.     
  1011.         $print->redirect_screen( $ibforums->lang['p_edited'], "act=SF&f=".$this->forum['id'] );
  1012.         
  1013.         
  1014.     }
  1015.         
  1016.         
  1017.     /*************************************************/
  1018.     // OPEN TOPIC:
  1019.     // ---------------
  1020.     //
  1021.     /*************************************************/
  1022.     
  1023.     function open_topic() {
  1024.         global $std, $ibforums, $DB, $print;
  1025.         
  1026.         if ($this->topic['state'] == 'open') {
  1027.             $this->moderate_error();
  1028.         }
  1029.         
  1030.         $passed = 0;
  1031.         
  1032.         if ($ibforums->member['g_is_supmod'] == 1) {
  1033.             $passed = 1;
  1034.         }
  1035.         
  1036.         else if ($this->topic['starter_id'] == $ibforums->member['id']) {
  1037.             if ($ibforums->member['g_open_close_topics'] == 1) {
  1038.                 $passed = 1;
  1039.             }
  1040.         }
  1041.         else
  1042.         {
  1043.             $passed = 0;
  1044.         }
  1045.         
  1046.         if ($this->moderator['open_topic'] == 1) {
  1047.             $passed = 1;
  1048.         }
  1049.         
  1050.         
  1051.         if ($passed != 1) $this->moderate_error();
  1052.         
  1053.         $this->alter_topic( array( 'TOPIC' => $this->topic['tid'], 'FIELD' => 'state', 'VALUE' => 'open' ) );
  1054.         
  1055.         $this->moderate_log("Opened Topic");
  1056.     
  1057.         $print->redirect_screen( $ibforums->lang['p_opened'], "act=ST&f=".$this->forum['id']."&t=".$this->topic['tid']."&st=".$ibforums->input['st'] );
  1058.         
  1059.     }
  1060.     
  1061.  
  1062.  
  1063.     /*************************************************/
  1064.     // CLOSE TOPIC:
  1065.     // ---------------
  1066.     //
  1067.     /*************************************************/
  1068.     
  1069.     function close_topic() {
  1070.         global $std, $ibforums, $DB, $print;
  1071.         
  1072.         $passed = 0;
  1073.         
  1074.         if ($ibforums->member['g_is_supmod'] == 1) {
  1075.             $passed = 1;
  1076.         }
  1077.         
  1078.         else if ($this->topic['starter_id'] == $ibforums->member['id']) {
  1079.             if ($ibforums->member['g_open_close_topics'] == 1) {
  1080.                 $passed = 1;
  1081.             }
  1082.         }
  1083.         else
  1084.         {
  1085.             $passed = 0;
  1086.         }
  1087.         
  1088.         if ($this->moderator['close_topic'] == 1) {
  1089.             $passed = 1;
  1090.         }
  1091.         
  1092.         
  1093.         if ($passed != 1) $this->moderate_error();
  1094.         
  1095.         $this->alter_topic( array( 'TOPIC' => $this->topic['tid'], 'FIELD' => 'state', 'VALUE' => 'closed' ) );
  1096.         
  1097.         $this->moderate_log("Locked Topic");
  1098.     
  1099.         $print->redirect_screen( $ibforums->lang['p_closed'], "act=SF&f=".$this->forum['id'] );
  1100.         
  1101.     }
  1102.  
  1103.  
  1104.     /*************************************************/
  1105.     // PIN TOPIC:
  1106.     // ---------------
  1107.     //
  1108.     /*************************************************/
  1109.     
  1110.     function pin_topic() {
  1111.         global $std, $ibforums, $DB, $print;
  1112.         
  1113.         if ($this->topic['PIN_STATE'] == 1) {
  1114.             $this->moderate_error();
  1115.         }
  1116.         
  1117.         $passed = 0;
  1118.         
  1119.         if ($ibforums->member['g_is_supmod'] == 1) {
  1120.             $passed = 1;
  1121.         }
  1122.         
  1123.         else if ($this->moderator['pin_topic'] == 1) {
  1124.             $passed = 1;
  1125.         }
  1126.         else {
  1127.             $passed = 0;
  1128.         }
  1129.         
  1130.         if ($passed != 1) $this->moderate_error();
  1131.         
  1132.         $this->alter_topic( array( 'TOPIC' => $this->topic['tid'], 'FIELD' => 'pinned', 'VALUE' => '1' ) );
  1133.         
  1134.         $this->moderate_log("Pinned Topic");
  1135.     
  1136.         $print->redirect_screen( $ibforums->lang['p_pinned'], "act=ST&f=".$this->forum['id']."&t=".$this->topic['tid']."&st=".$ibforums->input['st'] );
  1137.         
  1138.     }
  1139.     
  1140.     /*************************************************/
  1141.     // UNPIN TOPIC:
  1142.     // ---------------
  1143.     //
  1144.     /*************************************************/
  1145.     
  1146.     function unpin_topic() {
  1147.         global $std, $ibforums, $DB, $print;
  1148.         
  1149.         if ($this->topic['pinned'] == 0) {
  1150.             $this->moderate_error();
  1151.         }
  1152.         
  1153.         $passed = 0;
  1154.         
  1155.         if ($ibforums->member['g_is_supmod'] == 1) {
  1156.             $passed = 1;
  1157.         }
  1158.         
  1159.         else if ($this->moderator['unpin_topic'] == 1) {
  1160.             $passed = 1;
  1161.         }
  1162.         else {
  1163.             $passed = 0;
  1164.         }
  1165.         
  1166.         if ($passed != 1) $this->moderate_error();
  1167.         
  1168.         $this->alter_topic( array( 'TOPIC' => $this->topic['tid'], 'FIELD' => 'pinned', 'VALUE' => '0' ) );
  1169.         
  1170.         $this->moderate_log("Unpinned Topic");
  1171.     
  1172.         $print->redirect_screen( $ibforums->lang['p_unpinned'], "act=ST&f=".$this->forum['id']."&t=".$this->topic['tid']."&st=".$ibforums->input['st'] );
  1173.         
  1174.     }
  1175.     
  1176. //+---------------------------------------------------------------------------------------------
  1177.     
  1178.             
  1179.     /*************************************************/
  1180.     // MODERATE ERROR:
  1181.     // ---------------
  1182.     //
  1183.     // Function for error messages in this script
  1184.     //
  1185.     /*************************************************/
  1186.     
  1187.     function moderate_error($msg = 'moderate_no_permission') {
  1188.         global $std;
  1189.         
  1190.         $std->Error( array( 'LEVEL' => 2, 'MSG' => $msg ) );
  1191.         
  1192.         // Make sure we exit..
  1193.         
  1194.         exit();
  1195.     }
  1196.     
  1197.     /*************************************************/
  1198.     // MODERATE LOG:
  1199.     // ---------------
  1200.     //
  1201.     // Function for adding the mod action to the DB
  1202.     //
  1203.     /*************************************************/
  1204.     
  1205.     function moderate_log($title = 'unknown') {
  1206.         global $std, $ibforums, $DB, $HTTP_REFERER, $QUERY_STRING;
  1207.         
  1208.         $db_string = $std->compile_db_string( array (
  1209.                                                         'forum_id'    => $ibforums->input['f'],
  1210.                                                         'topic_id'    => $ibforums->input['t'],
  1211.                                                         'post_id'     => $ibforums->input['p'],
  1212.                                                         'member_id'   => $ibforums->member['id'],
  1213.                                                         'member_name' => $ibforums->member['name'],
  1214.                                                         'ip_address'  => $ibforums->input['IP_ADDRESS'],
  1215.                                                         'http_referer'=> $HTTP_REFERER,
  1216.                                                         'ctime'       => time(),
  1217.                                                         'topic_title' => $this->topic['title'],
  1218.                                                         'action'      => $title,
  1219.                                                         'query_string'=> $QUERY_STRING,
  1220.                                                     )
  1221.                                             );
  1222.         
  1223.         $DB->query("INSERT INTO ibf_moderator_logs (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
  1224.         
  1225.     }
  1226.     
  1227.     
  1228.     /*************************************************/
  1229.     // Re Count topics for the forums:
  1230.     // ---------------
  1231.     //
  1232.     // Handles simple moderation functions, saves on
  1233.     // writing the same code over and over.
  1234.     // ASS_U_ME's that the requesting user has been
  1235.     // authenticated by this stage.
  1236.     //
  1237.     /*************************************************/
  1238.     
  1239.     function recount($fid="") {
  1240.         global $ibforums, $root_path, $DB, $std;
  1241.         
  1242.         if ($fid == "")
  1243.         {
  1244.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'move_no_source' ) );
  1245.         }
  1246.         
  1247.         // Get the topics..
  1248.         
  1249.         $DB->query("SELECT COUNT(tid) as count FROM ibf_topics WHERE approved=1 and forum_id='".$fid."'");
  1250.         $topics = $DB->fetch_row();
  1251.         
  1252.         // Get the posts..
  1253.         
  1254.         $DB->query("SELECT COUNT(pid) as count FROM ibf_posts WHERE queued <> 1 and forum_id='".$fid."'");
  1255.         $posts = $DB->fetch_row();
  1256.         
  1257.         // Get the forum last poster..
  1258.         
  1259.         $DB->query("SELECT tid, title, last_poster_id, last_poster_name, last_post FROM ibf_topics WHERE approved=1 and forum_id='".$fid."' ORDER BY last_post DESC LIMIT 0,1");
  1260.         $last_post = $DB->fetch_row();
  1261.         
  1262.         // Reset this forums stats
  1263.         
  1264.         $db_string = $DB->compile_db_update_string( array (
  1265.                                                              'last_poster_id'   => $last_post['last_poster_id'],
  1266.                                                              'last_poster_name' => $last_post['last_poster_name'],
  1267.                                                              'last_post'        => $last_post['last_post'],
  1268.                                                              'last_title'       => $last_post['title'],
  1269.                                                              'last_id'          => $last_post['tid'],
  1270.                                                              'topics'           => $topics['count'],
  1271.                                                              'posts'            => $posts['count']
  1272.                                                  )        );
  1273.                                                  
  1274.         $DB->query("UPDATE ibf_forums SET $db_string WHERE id='".$fid."'");
  1275.         
  1276.     }
  1277.     
  1278.     
  1279.     /*************************************************/
  1280.     // ALTER TOPIC:
  1281.     // ---------------
  1282.     //
  1283.     // Handles simple moderation functions, saves on
  1284.     // writing the same code over and over.
  1285.     // ASS_U_ME's that the requesting user has been
  1286.     // authenticated by this stage.
  1287.     //
  1288.     /*************************************************/
  1289.     
  1290.     function alter_topic( $data = array() ) {
  1291.         global $ibforums, $DB;
  1292.         
  1293.         if ( $data['FIELD'] == "" ) return -1;
  1294.         if ( $data['VALUE'] == "" ) return -1;
  1295.         if ( $data['TOPIC'] == "" ) return -1;
  1296.         
  1297.         if ($data['TOPIC'] < 1) return -1;
  1298.         
  1299.         $data['VALUE'] = preg_replace( "/'/", "\\'", $data['VALUE'] );
  1300.         
  1301.         $DB->query("UPDATE ibf_topics SET ".$data['FIELD']."='".$data['VALUE']."' WHERE tid='".$data['TOPIC']."'");
  1302.     }
  1303.         
  1304.     /*****************************************************/
  1305.     // HTML: start form.
  1306.     // ------------------
  1307.     // Returns the HTML for the <FORM> opening tag
  1308.     /*****************************************************/
  1309.     
  1310.     function html_start_form($additional_tags=array()) {
  1311.         global $ibforums;
  1312.         
  1313.         $form = "<form action='{$this->base_url}' method='POST' name='REPLIER'>".
  1314.                 "<input type='hidden' name='st' value='".$ibforums->input[st]."'>".
  1315.                 "<input type='hidden' name='act' value='Mod'>".
  1316.                 "<input type='hidden' name='s' value='".$ibforums->session_id."'>".
  1317.                 "<input type='hidden' name='f' value='".$this->forum['id']."'>";
  1318.                 
  1319.         // Any other tags to add?
  1320.         
  1321.         if (isset($additional_tags)) {
  1322.             foreach($additional_tags as $k => $v) {
  1323.                 $form .= "\n<input type='hidden' name='{$v[0]}' value='{$v[1]}'>";
  1324.             }
  1325.         }
  1326.         
  1327.         return $form;
  1328.     }
  1329.     
  1330. }
  1331.  
  1332. ?>
  1333.